package OOP.day10.homework.AnimalDemo05;

public class PolymorphicDemo {
    public static void main(String[] args) {
        Animal[] animals = new Animal[5];
        animals[0] = new Dog("wangcai", 3,"black");
        animals[1] = new Chick("kitty", 2,"white");
        animals[2] = new Fish("King", 3,"gold");
        animals[3] = new Dog("tiezhu", 1,"white");
        animals[4] = new Chick("boboji", 1,"yellow");
        for (Animal animal : animals){
            System.out.println(animal.name);
            animal.eat();
            animal.drink();
            if (animal instanceof Dog){
                ((Dog) animal).lookHome();
            } else if (animal instanceof Chick){
                ((Chick) animal).layeggs();
            } else if (animal instanceof Swim){
                ((Swim) animal).swim();
            }
        }
        Master master = new Master();
        master.feed(new Dog("旺财",3,"白"));
        master.feed(new Chick("小鸡",2,"白"));
        master.feed(new Fish("小金鱼",3,"金"));
    }

}
